package tcp1;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
	public static void main(String[] args) throws IOException {
		ServerSocket server = new ServerSocket(9999);
		Socket socket = server.accept();

		InputStream is = socket.getInputStream();
		byte[] b = new byte[1024];
		OutputStream out = new FileOutputStream(" d:\\2.jpg");
		int len = -1;
		while ((len = is.read(b)) != -1) {
			out.write(b, 0, len);
		}
		out.flush();
		out.close();
		is.close();
		socket.close();
		server.close();

	}
}
